from random import *

class Gui():
    def __init__(self):  #体力、位置
        self.tili=100
        self.locationx=randint(0,10)
        self.locationy=randint(0,10)

    def location(self):
        print("乌龟初始位置为x=%d,y=%d"%(self.locationx,self.locationy))

    def move(self):
        if choice([0, 1]):
            self.locationx += choice([-2, -1, 1, 2])
            if self.locationx < 0:
                self.locationx = 0 - self.locationx
            elif self.locationx > 10:
                self.locationx = 10 - (self.locationx - 10)
        else:
            self.locationy += choice([-2, -1, 1, 2])
            if self.locationy <= 0:
                self.locationx = 0 - self.locationx
            elif self.locationy >= 10:
                self.locationx = 10 - (self.locationx - 10)
        self.tili -= 20

    def now(self):
        print("乌龟的现在位置为：\n(%d,%d)\n" % (self.locationx, self.locationy))
        print("乌龟剩余体力为：", self.tili)

    def eat(self):
        self.tili+=20
        if self.tili>100:
            self.tili=100

class Yu():
    def __init__(self):
        self.tili = 10
        self.yulocalx=randint(0, 10)
        self.yulocaly=randint(0, 10)

    def locationY(self):
        print("鱼初始位置为",end="")
        print("(%d,%d)\n" % (self.yulocalx, self.yulocaly),end="")

    def remove(self):
        if choice([0, 1]):
            self.yulocalx += choice([-1, 1])
            if self.yulocalx < 0:
                self.yulocalx = 0 - self.yulocalx
            elif self.yulocalx> 10:
                self.yulocalx = 10 - (10 - self.yulocalx)
        else:
            self.yulocaly += choice([-1, 1])
            if self.yulocaly < 0:
                self.yulocaly = 0 - self.yulocaly
            elif self.yulocaly > 10:
                self.yulocaly = 10 - (10 - self.yulocaly)
        self.tili -= 1

    def now(self):
        print("鱼现在的位置为:",self.yulocal)
        print("鱼剩余数列量：",self.num)

def game():
    gui = Gui()
    yu = Yu()
    i = 1
    while 1:
        print("第%d步\n" % i)
        gui.move()
        yu.move()
        gui.now()
        yu.now()
        i += 1
        for each in yu.fishLocal:
            if each[0] == gui.localx and each[1] == gui.localy:
                yu.num -= 1
                yu.fishLocal.remove(each)
            if gui.force <= 0:
                return "乌龟失败啦，鱼是赢家！"
            if gui.num <= 0:
                return "鱼失败啦，乌龟是赢家！"

gui=Gui()
fish=[]
a=1
gui.location()
for i in range(10):  #10条鱼
    new_yu=Yu()
    fish.append(new_yu)
for i in fish:      #10条鱼的位置
    print(a,end="")
    i.locationY()
    a+=1
s=1
while 1:
    print("第%d步\n" % s)
    # yu.move()
    # yu.now()
    s += 1
    if not len(fish):
        print('乌龟把鱼都吃完了，游戏结束')
        break
    if not gui.tili:
        print('乌龟体力耗尽了，游戏结束')
        break
    gui.move()
    gui.now()
    for num in fish:
        print('小鱼移动前坐标：（%d,%d)' % (num.yulocalx, num.yulocaly))
        num.remove()
        print('小鱼移动后坐标：（%d,%d）' % (num.yulocalx, num.yulocaly))
        if num.yulocalx == gui.locationx and num.yulocaly == gui.locationy:
            gui.eat()
            fish.remove(num)
            print('乌龟吃了一条鱼')
            print('乌龟的体力值为：%d' % gui.tili)






